package com.zzxx.wechat.controller;

import com.alibaba.fastjson.JSON;
import com.zzxx.wechat.common.vo.ArcteryxLinkVo;
import com.zzxx.wechat.result.R;
import com.zzxx.wechat.service.ArcteryxLinkService;
import com.zzxx.wechat.service.ArcteryxService;
import com.zzxx.wechat.service.ArcteryxTaskService;
import com.zzxx.wechat.service.NewCommodityService;
import com.zzxx.wechat.service.api.WechatService;
import com.zzxx.wechat.util.HttpProxyClient;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

@Controller
public class HelloController {

    private static final Logger log = LoggerFactory.getLogger(HelloController.class);
    @Autowired
    ArcteryxService arcteryxService;

    @Autowired
    WechatService wechatService;
    @Autowired
    WxMpService wxMpService;
    @Resource
    private ArcteryxTaskService arcteryxTaskService;
    @Resource
    private ArcteryxLinkService arcteryxLinkService;

    @Value("${new.commodity.notice.template.id}")
    private String newCommodityNoticeTemplateId;


    @Autowired
    NewCommodityService newCommodityService;

    @GetMapping("aaa")
    @ResponseBody
    public R<Void> aaa() {
        return R.ok();
    }


    @GetMapping("demo")
    @ResponseBody
    public R<List<ArcteryxLinkVo>> demo() throws IOException {

        List<ArcteryxLinkVo> arcteryxLinkVos = arcteryxLinkService.queryLinkByProductNo("X000009141");

        return R.ok(arcteryxLinkVos);
    }

    @Resource
    private HttpProxyClient httpProxyClient;

    @GetMapping("test")
    @ResponseBody
    public R<Void> test() throws IOException {


       // String htmlStr = httpProxyClient.doGetIgnoreSsl("https://arcteryx.com/us/en/shop/X000010086");
        String htmlStr = httpProxyClient.doGetIgnoreSsl("https://wbiprod.storedvalue.com/wbir/clients/arcteryx?lng=en");

        log.info("htmlStr:{}", htmlStr);
        arcteryxService.analysisUrl("https://arcteryx.com/us/en/shop/X000010086");
        // arcteryxService.analysisUrl("https://arcteryx.com/us/en/shop/X000009141");888888
        //arcteryxService.analysisUrl("https://outlet.arcteryx.com/ca/zh/shop/conveyor-belt-32");
        // arcteryxService.analysisUrl("https://outlet.arcteryx.com/gb/en/shop/womens/beta-jacket-8064");
        return R.ok();
    }

}
